import React from 'react';
import Loading from "../component/Loading";
import Loadable from 'react-loadable';
import {routerRedux} from 'dva/router';
import {Route, Switch} from "react-router-dom";
import {setHistory} from "../util/uitls";
// import RequireAuth from "../component/authCompont";
/*const Home = Loadable({
    loader: () => import('../page/general/home/index.js'),
    loading: Loading
});*/
const FriendQuan = Loadable({
    loader: () => import('../page/friendQuan/index.js'),
    loading: Loading
});
const AddFriendQuanText = Loadable({
    loader: () => import('../page/addFriendQuanText/index.js'),
    loading: Loading
});
const AddFriend = Loadable({
    loader: () => import('../page/addFriend/index.js'),
    loading: Loading
});
const FriendList = Loadable({
    loader: () => import('../page/friendList/index.js'),
    loading: Loading
});
const HomeFilter = Loadable({
    loader: () => import('../page/homeFilter/index.js'),
    loading: Loading
});
const TalkOne = Loadable({
    loader: () => import('../page/talkOne/index.js'),
    loading: Loading
});
const MySelf = Loadable({
    loader: () => import('../page/mySelf/index.js'),
    loading: Loading
});
const TalkList = Loadable({
    loader: () => import('../page/TalkList/index.js'),
    loading: Loading
});
const Home = Loadable({
    loader: () => import('../page/Home/index.js'),
    loading: Loading
});
const Login = Loadable({
    loader: () => import('../page/login/index.js'),
    loading: Loading
});
const LoginWithMobileCode = Loadable({
    loader: () => import('../page/loginWithMobileCode/index.js'),
    loading: Loading
});
const RegisterMobile = Loadable({
    loader: () => import('../page/register/RegisterMobile.js'),
    loading: Loading
});
const RegisterMobileCode = Loadable({
    loader: () => import('../page/register/registerMobileCode.js'),
    loading: Loading
});


const {ConnectedRouter} = routerRedux;


export default ({history, app}) => {

    return (<ConnectedRouter history={history}>

            <Switch>
                {
                    setHistory(history)
                }
                <Route exact path="/" component={Home}/>
                <Route exact path="/home" component={Home}/>
                <Route exact path="/home-filter" component={HomeFilter}/>
                <Route exact path="/login" component={Login}/>
                <Route exact path="/login-mobile" component={LoginWithMobileCode}/>
                <Route exact path="/register-mobile" component={RegisterMobile}/>
                <Route exact path="/register-mobile-code" component={RegisterMobileCode}/>
                <Route exact path="/talk/:id" component={TalkOne}/>
                <Route exact path="/talk-list" component={TalkList}/>
                <Route exact path="/my-self" component={MySelf}/>
                <Route exact path="/friend-list" component={FriendList}/>
                <Route exact path="/friend-quan" component={FriendQuan}/>
                <Route exact path="/add-friend" component={AddFriend}/>

                <Route exact path="/add-friend-quan-text" component={AddFriendQuanText}/>


            </Switch>
        </ConnectedRouter>
    );
}

